package com.wisdytech.linkdcs.report.action;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.wisdytech.common.handler.ResourceMatchingService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wisdytech.common.bean.Filter;
import com.wisdytech.common.bean.StandardResult;
import com.wisdytech.common.bean.StandardTableResult;
import com.wisdytech.linkdcs.report.dto.HistorySearchDTO;
import com.wisdytech.linkdcs.report.service.IReportService;
import com.wisdytech.linkdcs.report.vo.AlarmHistoryVO;
import com.wisdytech.linkdcs.report.vo.StopHistoryVO;


/**
 * 
 * <p>ClassName: ReportAction</p>
 * <p>Description: 报表统计action</p>
 * <p>Author: dailibo</p>
 * <p>Date: 2017-10-13</p>
 */
@Controller
@RequestMapping("/report")
public class ReportAction {
    
    
    @Resource
    private IReportService reportService;
    @Autowired
    @Qualifier("resourceMatchingService")
    private ResourceMatchingService resourceMatchingService;
    @RequestMapping("/stop/index")
    public String index(Model model,String emModel, HttpServletRequest httpRequest){
        this.resourceMatchingService.getResourceName(httpRequest,model);
        if(StringUtils.isNotBlank(emModel)){
            model.addAttribute("emModel",emModel);
        }
        return "report/stopHistory";
    }
    
    @RequestMapping("/alarm/index")
    public String alarmIndex(Model model,String emModel, HttpServletRequest httpRequest){
        this.resourceMatchingService.getResourceName(httpRequest,model);
        if(StringUtils.isNotBlank(emModel)){
            model.addAttribute("emModel",emModel);
        }
        
        return "report/alarmHistory";
    }
    
    /**
     * 
     * <p>Description: 分页获取</p>
     * @return
     */
    @RequestMapping("/stop/listHistory/get.mvc")
    @ResponseBody
    public StandardTableResult<StopHistoryVO> listStopHistory(Filter filter ,HistorySearchDTO search){
       
        return reportService.listStopHistory(filter, search);
    }
    
    @RequestMapping("/stop/listHistoryAnalysis/get.mvc")
    @ResponseBody
    public StandardResult listStopHistoryAnalysis(HistorySearchDTO search){
        return reportService.listStopHistoryAnalysis(search);
    }
    
    
    /**
     * 
     * <p>Description: 分页获取</p>
     * @return
     */
    @RequestMapping("/alarm/listHistory/get.mvc")
    @ResponseBody
    public StandardTableResult<AlarmHistoryVO> listAlarmHistory(Filter filter ,HistorySearchDTO search){
       
        return reportService.listAlarmHistory(filter, search);
    }
    
    @RequestMapping("/alarm/listHistoryAnalysis/get.mvc")
    @ResponseBody
    public StandardResult listAlarmHistoryAnalysis(HistorySearchDTO search){
        return reportService.listAlarmHistoryAnalysis(search);
    }
    
    
    
    

}
